﻿
                                  <div class="box border primary">
											<div class="box-title">
												<h4><i class="fa fa-bars"></i>Form controls</h4>
												<div class="tools hidden-xs">
													<a href="#box-config" data-toggle="modal" class="config">
														<i class="fa fa-cog"></i>
													</a>
													<a href="javascript:;" class="reload">
														<i class="fa fa-refresh"></i>
													</a>
													<a href="javascript:;" class="collapse">
														<i class="fa fa-chevron-up"></i>
													</a>
													<a href="javascript:;" class="remove">
														<i class="fa fa-times"></i>
													</a>
												</div>
											</div>

											<div class="box-body big">
												<h3 class="form-title">权限添加</h3>
												<form method="post" action="" class="form-horizontal" role="form" enctype="multipart/form-data">
												  <div class="form-group">
													<label class="col-sm-3 control-label">分类归属</label>
													<div style="width:auto;float:left" class="col-sm-1 pid">
													  <select name='pid' class="form-control" style="width:120px;float:left">
													         <option value="0">顶级分类</option>
													     <?php foreach($date as $v):?>
                                                         <option value="<?php echo $v['id'];?>" ><?php echo $v['name']?></option>
                                                          <?php endforeach;?>
													  </select>

													</div>
												  </div>


												  <div class="form-group">
													<label class="col-sm-3 control-label">权限名称</label>
													<div class="col-sm-9">
													  <input name="name" class="form-control" placeholder="" type="text">
													</div>
												  </div>

												  <div class="form-group">
													<label class="col-sm-3 control-label">url</label>
													<div class="col-sm-9">
													  <input disabled name="url" class="form-control"  type="text">
													</div>
												  </div>
	  
                                                <div class="col-sm-offset-3 col-sm-13">
                                                 <button type="submit" class="btn btn-success">提交</button>
													</div>
												 </form>
											</div>

										</div>
<script src="public/admin/js/jquery/jquery-2.0.3.min.js"></script>

<script type="text/javascript">
$(function(){
	//选中顶级分类就将url的值清空并且设置disabled值
	$('select[name=pid]').change(function(){
		if($(this).get(0).selectedIndex==0){
		   $('input[name=url]').val('');
           $('input[name=url]').attr('disabled',true);
		}else{
		   
		   $('input[name=url]').attr('disabled',false);
		}
	});
})
</script>
